babl: babl_log() implementation for Android.
authorJehan <jehan@girinstud.io>
Tue, 4 Jul 2017 14:35:46 +0000 (16:35 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 13 Sep 2017 16:28:55 +0000 (18:28 +0200)
babl/Makefile.am
babl/babl-internal.h
configure.ac

index bc13d954261ee61434eaa3fb401b2fca24b1a981..c902325b8f539bd04dc68f1a883ec274191227fe 100644 (file)
@@ -99,7 +99,7 @@ libbabl_@BABL_API_VERSION@_la_LIBADD= \
        @LTLIBOBJS@
 
 libbabl_@BABL_API_VERSION@_la_LDFLAGS=                 \
-       ${no_undefined} $(MATH_LIB) $(THREAD_LIB)       \
+       ${no_undefined} $(MATH_LIB) $(THREAD_LIB) $(LOG_LIB) \
        -version-info $(BABL_LIBRARY_VERSION)
 
 EXTRA_DIST = babl-ref-pixels.inc
index a4dc5f743a86e057a471984fb938868839057bea..24ad347885a318e561cb2924e25270b027e72604 100644 (file)
@@ -58,6 +58,9 @@
 # define rint(f)  (floor (((double) (f)) + 0.5))
 #endif
 
+#ifdef __ANDROID_API__
+#include <android/log.h>
+#endif
 
 
 Babl *   babl_conversion_find           (const void     *source,
@@ -123,15 +126,33 @@ real_babl_log_va(const char *file,
   if (extender != babl_extension_quiet_log())
     {
       if (babl_extender())
-        fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+        {
+#ifdef __ANDROID_API__
+          __android_log_print (ANDROID_LOG_DEBUG, "BABL",
+                               "When loading %s:\n\t", babl_extender()->instance.name);
+#else
+          fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+#endif
+        }
 
+#ifdef __ANDROID_API__
+      __android_log_print (ANDROID_LOG_DEBUG, "BABL",
+                           "%s:%i %s()\n\t", file, line, function);
+#else
       fprintf (stdout, "%s:%i %s()\n\t", file, line, function);
+#endif
     }
 
+#ifdef __ANDROID_API__
+  __android_log_vprint (ANDROID_LOG_DEBUG, "BABL",
+                        fmt, varg);
+  __android_log_write (ANDROID_LOG_DEBUG, "BABL", "\n");
+#else
   vfprintf (stdout, fmt, varg);
 
   fprintf (stdout, "\n");
   fflush (NULL);
+#endif
   return;
 }
 
index 08d10ac66519c961a474934f9f4b94656bba7cad..4abcfcabf31db9165228e188ec1a33f3f391a397 100644 (file)
@@ -255,6 +255,7 @@ AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
 
 MATH_LIB=-lm
 THREAD_LIB=-lpthread
+LOG_LIB=
 AC_MSG_CHECKING([for native Win32])
 case "$target_or_host" in
   *-*-mingw*)
@@ -269,6 +270,7 @@ case "$target_or_host" in
     PATH_SEP=':'
     DIR_SEP='/'
     THREAD_LIB=
+    LOG_LIB='-llog'
     ;;
   *)
     os_win32=no
@@ -281,6 +283,7 @@ AC_SUBST(PATH_SEP)
 AC_SUBST(DIR_SEP)
 AC_SUBST(MATH_LIB)
 AC_SUBST(THREAD_LIB)
+AC_SUBST(LOG_LIB)
 
 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
 AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")